package com.edais.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.edais.domain.GetKeyCodeRecode;
import com.edais.domain.UserActivityKeyCode;
import com.edais.persistence.KeycodeSendRecordMapper;

/**
 * 
  * ClassName: KeycodeSendRecordDao.java 
  * @Description: 
  * @author ruXinChao
  * @date 2016-9-18 下午3:45:21
 */
@Repository
public class KeycodeSendRecordDao {
	
	@Autowired
	private KeycodeSendRecordMapper keycodeSendRecordMapper;
	
	/**
	 * 
	 * @Description:  增加短信发送记录
	 * @param getKeyCodeRecode
	 * @return  
	 * @return int  
	 * @author ruXinChao
	 * @date 2016-9-19  下午4:30:21
	 */
	public int insertSelective(GetKeyCodeRecode getKeyCodeRecode){
		return keycodeSendRecordMapper.insertSelective(getKeyCodeRecode);
	}
	
	/**
	 * 
	 * @Description: 更新K码发送表状态
	 * @param map
	 * @return  
	 * @return int  
	 * @author ruXinChao
	 * @date 2016-9-19  下午5:48:06
	 */
	public int updateKCodeSendStatus(Map<String, Object> map){
		return keycodeSendRecordMapper.updateKCodeSendStatus(map);
	}
	/**
	 * 
	 * @Description: 更新T_USER_ACTIVITY_KEYCODE_LIST 的状态根据cardeNo
	 * @param map
	 * @return  
	 * @return int  
	 * @author ruXinChao
	 * @date 2016-9-19  下午6:00:21
	 */
	public int updateActivityKeyCodeByCardNo(Map<String, Object> map){
		return keycodeSendRecordMapper.updateActivityKeyCodeByCardNo(map);
	}
	/**
	 * 
	 * @Description:  根据参数获得K码发送信息
	 * @param map
	 * @return
	 * @throws Exception  
	 * @return List<GetKeyCodeRecode>  
	 * @author ruXinChao
	 * @date 2016-9-18  下午3:47:57
	 */
	public List<GetKeyCodeRecode> getKeyCodeRecodeByParm(Map<String,Object> map) throws Exception{
		return keycodeSendRecordMapper.getKeyCodeRecodeByParm(map);
	}
	
	/**
	 * 
	 * @Description:根据用户ID获得K码发送信息
	 * @param userId
	 * @return
	 * @throws Exception  
	 * @return GetKeyCodeRecode  
	 * @author ruXinChao
	 * @date 2016-9-18  下午3:49:30
	 */
	public  GetKeyCodeRecode getKeyCodeRecodeByUserId(String userId) throws Exception{
		return keycodeSendRecordMapper.getKeyCodeRecodeByUserId(userId);
	}

	/**
	 * 
	 * @Description: 根据渠道拿出10条该渠道未分配的code
	 * @param channelId 渠道Id
	 * @return  
	 * @return UserActivityKeyCode  
	 * @author ruXinChao
	 * @date 2016-9-19  下午3:11:21
	 */
	public List<UserActivityKeyCode> getKeyCodeListByParm(Integer channelId) throws Exception{
		return keycodeSendRecordMapper.getKeyCodeListByParm(channelId);
	}

	/**
	 * 
	 * @Description: 根据渠道Id获得加密密钥
	 * @param id 渠道id
	 * @return
	 * @throws Exception  
	 * @return HashMap<String,Object>  
	 * @author ruXinChao
	 * @date 2016-9-20  下午1:25:27
	 */
	public HashMap<String, Object> getSecretKey(Integer id)throws Exception{
		return keycodeSendRecordMapper.getSecretKey(id);
	}

	
	/**
	 * 
	 * @Description: 获得发送K码短信的Url 域名（ip+端口）
	 * @param ipPort
	 * @return  
	 * @return HashMap<String,Object>  
	 * @author ruXinChao
	 * @date 2016-9-21  上午10:55:28
	 */
	public HashMap<String, Object> getSendMsgKcodeUrl(String ipPort){
		return keycodeSendRecordMapper.getSendMsgKcodeUrl(ipPort);
	}


}
